import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * Created by wangyg on 2016/11/2.
 */
public class TestCalendar {
	//	public static void main(String[] args) {
	//
	//		Calendar calendar =Calendar.getInstance();
	//		calendar.setTime(new Date());
	//		System.out.println(calendar.getTime());
	////		System.out.println(calendar);
	//		calendar.add(Calendar.MONTH,-1);
	//		System.out.println(calendar.getTime());
	//
	//
	//		calendar.set(2016,10,3);
	////		System.out.println(calendar.getTime());
	////		calendar.add(Calendar.MONTH,-1);
	////		System.out.println(calendar.getTime());
	////		calendar.set(Calendar.DAY_OF_MONTH,1);
	//		System.out.println(calendar.getTime());
	//
	//		if(Calendar.getInstance().compareTo(calendar)<=0){
	//			System.out.println("wo ai ni");
	//		}
	//	}
	//三天打鱼，两天晒网
	public static void main(String[] args) {
		while (true) {
			System.out.println("请输入时间，形如20160101");
			Scanner scanner = new Scanner(System.in);
			String value = scanner.next();
			String realValue = value + "000000";
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
			Calendar calendar = Calendar.getInstance();
			Date time = null;
			Date time2 = null;
			try {
				time = sdf.parse(realValue);
				time2 = sdf.parse("19900101000000");
			} catch (ParseException e) {
				System.out.println("Invalid input");
				break;
			}
			calendar.setTime(time);
			System.out.println(calendar.getTime());

			//		获取那个时间距离1990年1月1日的天数
			long days = (long) Math
					.ceil(Math.abs(calendar.getTimeInMillis() - time2.getTime()) / 1000 / 60 / 60 / 24.0);
			System.out.println("输入的日期为："+value+"转换的日期为"+calendar.getTime()+ "。距离1990-01-01日共计" + days + "天");
			long n = days % 5;
			System.out.println("如果1990-01-01为开始，三天打鱼，两天晒网。那么今天：");
			if (n < 3) {
				System.out.println("He is working");
			} else {
				System.out.println("He is Having a reset");
			}

			String json="";
		}
	}
}
